/*
*    Phantom v2.0 GUI Automation Software
*    Copyright (C) 2009  John C. Van Arsdall (john@phantomtest.com)
*
*    This program is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License along
*    with this program; if not, write to the Free Software Foundation, Inc.,
*    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
// PhantomAgentDlg.h : header file
//

#pragma once

#include <list>
using std::list;

#include "Connection.h"
#include "ssi_std_options.h"
#include "afxcmn.h"

#define ERR_TITLE    "Phantom Agent Error"

#define ID_HOST_TITLE "Host"
#define ID_HOST_ID    0

#define ID_PORT_TITLE "ID"
#define ID_PORT_ID    1

#define ID_STAT_TITLE "Status"
#define ID_STAT_ID    2

#define ID_SENT_TITLE "Sent"
#define ID_SENT_ID    3

#define ID_RECV_TITLE "Received"
#define ID_RECV_ID    4

#define ID_INFO_TITLE "Additional Info"
#define ID_INFO_ID    5


// CPhantomAgentDlg dialog
class CPhantomAgentDlg : public CDialog
{
// Construction
public:
	CPhantomAgentDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_PHANTOMAGENT_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	CListCtrl* ConnectionList;
	int AddConnection(const char* inHost, const char* inPort);
	int AddConnection(CConnection* inConnection);
	int CleanConnections(bool bALL);
protected:
	std::list<CConnection*> Connections;
public:
	afx_msg void OnTimer(UINT nIDEvent);
	UINT TimerHandle;
	std_options options;
	void ValidateOptions(void);
	void DispErrorBox(const char* sMess);
	void UpdateDataDisplay(void);
	void UpdateConnections(void);
	int m_RecvCnt;
	int m_SentCnt;
	void InitControls(void);
	afx_msg void OnViewOptions();
	afx_msg void OnViewHide();
	afx_msg void OnViewExit();
	BOOL SetIconic(void);
	BOOL RemoveIconic();
	virtual BOOL DestroyWindow();
	LRESULT OnTrayNotify(WPARAM uID, LPARAM lEvent);
	void OnPopupHide();
	void OnPopupShow();
	BOOL m_HiddenFlg;
  BOOL m_FirstTimer;
	CToolBarCtrl m_ToolBar;
  void InitLogFile(void);
  BOOL bRegistered;
};
